home *** CD-ROM | disk | FTP | other *** search
- /*
-
- File: CAS_Dialog.c
-
- Contains: Utility routines for dialogs & controls.
-
- Written by: David H Nelson
-
- Copyright © 1988-1995 ComponentWorks, All rights reserved.
-
- Change History (most recent first):
-
- 01/17/95 DAS changed all FrontWindow() calls to
- App_GetFrontDocWindow() to account for
- floating windows.
- 1/14/95 DAS conversion of some DialogMgr API calls into their new names
- 1/15/95 DHN Fixed bDialogFilter results so it doesn't handle keystrokes
- that it shouldn't. Changed many variable names for clarity.
- ----------------------------
- ?/?/88 DHN Created.
- */
-
- #ifdef USE_CALIB
- #include "CALib.h"
- #endif
-
- #include "CAS_Globals.h"
-
- #include "CAS_Dialog.h"
- #include "CAS_App.h"
- #include "CAS_StringTools.h"
-
-
-
- //----------------------------------------------------------------------------
- void Dialog_CenterALRT(
- short ID )
- {
- Rect rScreen;
- AlertTHndl theALRT;
-
- theALRT = (AlertTHndl)GetResource( 'ALRT', ID );
- if (theALRT == nil)
- return;
-
- GetMainScreenRect( &rScreen );
- rScreen.top += GetMBarHeight() + 4;
-
- rCenterRectInRect( &rScreen, &((**theALRT).boundsRect) );
-
- ChangedResource( (Handle)theALRT );
- ReleaseResource( (Handle)theALRT );
- }
-
- //----------------------------------------------------------------------------
- void Dialog_CenterALRTonFrontWindow(
- short ID )
- {
- Rect rFrontWindow;
- AlertTHndl theALRT;
- WindowPtr theWindow;
-
- theALRT = (AlertTHndl)GetResource( 'ALRT', ID );
- if (theALRT == nil)
- return;
-
- // DAS: changed from FrontWindow() to App_GetFrontDocWindow to handle
- // floating windows.
- theWindow = App_GetFrontDocWindow();
- if (theWindow == nil)
- GetMainScreenRect( &rFrontWindow );
- else
- rFrontWindow = theWindow->portRect;
- RectLocalToGlobal( &rFrontWindow );
- rCenterRectInRect( &rFrontWindow, &((**theALRT).boundsRect) );
-
- // If the top-left or bot-right corners of the dialog are off screen, center
- // the dialog on the main screen. (Note: It is not possible to correctly move
- // the window onto the desktop region nearest the center point without parsing
- // the rgn.)
- if (!PtInRgn( topLeft((**theALRT).boundsRect), LMGetGrayRgn() ) ||
- !PtInRgn( botRight((**theALRT).boundsRect), LMGetGrayRgn() ))
- {
- GetMainScreenRect( &rFrontWindow );
- rCenterRectInRect( &rFrontWindow, &((**theALRT).boundsRect) );
- }
-
- ChangedResource( (Handle)theALRT );
- ReleaseResource( (Handle)theALRT );
- }
-
- //----------------------------------------------------------------------------
- // Center the given DLOG on the front most window.
- // This must be called before GetNewDialog.
-
- void Dialog_CenterDLOG(
- short ID )
- {
- Rect rScreen;
- DialogTHndl theDLOG;
-
- theDLOG = (DialogTHndl)GetResource( 'DLOG', ID );
- if (theDLOG == nil)
- return;
-
- GetMainScreenRect( &rScreen );
- rScreen.top += GetMBarHeight() + 4;
-
- rCenterRectInRect( &rScreen, &((**theDLOG).boundsRect) );
-
- ChangedResource( (Handle)theDLOG );
- ReleaseResource( (Handle)theDLOG );
- }
-
- //----------------------------------------------------------------------------
- // Center the given DLOG on the front most window. This must be called before
- // GetNewDialog.
-
- void Dialog_CenterDLOGonFrontWindow(
- short ID )
- {
- Rect rFrontWindow;
- DialogTHndl theDLOG;
- WindowPtr theWindow;
-
- theDLOG = (DialogTHndl)GetResource( 'DLOG', ID );
- if (theDLOG == nil)
- return;
-
- // DAS: changed from FrontWindow() to App_GetFrontDocWindow to handle
- // floating windows.
- theWindow = App_GetFrontDocWindow();
- if (theWindow == nil)
- GetMainScreenRect( &rFrontWindow );
- else
- rFrontWindow = theWindow->portRect;
- RectLocalToGlobal( &rFrontWindow );
- if (theWindow == nil)
- GetMainScreenRect( &rFrontWindow );
-
- rCenterRectInRect( &rFrontWindow, &((**theDLOG).boundsRect) );
-
- // If the top-left or bot-right corners of the dialog are off screen, center
- // the dialog on the main screen. (Note: It is not possible to correctly move
- // the window onto the desktop region nearest the center point without parsing
- // the rgn.)
- if (!PtInRgn( topLeft((**theDLOG).boundsRect), LMGetGrayRgn() ) ||
- !PtInRgn( botRight((**theDLOG).boundsRect), LMGetGrayRgn() ))
- {
- GetMainScreenRect( &rFrontWindow);
- rCenterRectInRect( &rFrontWindow, &((**theDLOG).boundsRect) );
- }
-
- ChangedResource( (Handle)theDLOG );
- ReleaseResource( (Handle)theDLOG );
- }
-
-
- //----------------------------------------------------------------------------
-
- Point Dialog_TopLeftCenteredDLOG(
- short iDLOG )
- {
- Handle hDialog;
- Rect rDialog, rScreen;
- Point targetPt;
-
- GetMainScreenRect( &rScreen );
- rScreen.top += GetMBarHeight() + 4;
-
- hDialog = GetResource( 'DLOG', iDLOG );
- if (hDialog == nil)
- {
- targetPt.h = 0;
- targetPt.v = 0;
- }
- else
- {
- rDialog = *(Rect*)*hDialog;
- rCenterRectInRect( &rScreen, &rDialog );
-
- targetPt.h = rDialog.left;
- targetPt.v = rDialog.top;
-
- ChangedResource( hDialog );
- ReleaseResource( hDialog );
- }
-
- return targetPt;
- }
-
- //---------------------------------------------------------------------------
- // given a dialog and a range of radio buttons, turn all off except activeItem.
-
- void Dialog_SetCheckBox(
- DialogPtr theDialog,
- short checkItem,
- Boolean bCheckValue )
- {
- ControlHandle theControl;
-
- theControl = (ControlHandle)Dialog_GetItemHandle( theDialog, checkItem );
- if (theControl != nil)
- SetControlValue( theControl, bCheckValue ? 1 : 0 );
- }
-
- //---------------------------------------------------------------------------
- // given a dialog and a range of radio buttons, turn all off except activeItem.
-
- Boolean Dialog_GetCheckBox(
- DialogPtr theDialog,
- short checkItem )
- {
- ControlHandle theControl;
-
- theControl = (ControlHandle)Dialog_GetItemHandle( theDialog, checkItem );
- if (theControl != nil)
- return (GetControlValue( theControl ) != 0);
-
- return false;
- }
-
- //---------------------------------------------------------------------------
- // given a dialog and a range of radio buttons, turn all off except activeItem.
-
- void Dialog_ToggleCheckBox(
- DialogPtr theDialog,
- short checkItem )
- {
- ControlHandle theControl;
-
- theControl = (ControlHandle)Dialog_GetItemHandle( theDialog, checkItem );
- if (theControl != nil)
- SetControlValue( theControl, GetControlValue( theControl ) ? 0 : 255 );
- }
-
- //---------------------------------------------------------------------------
- // given a dialog and a range of radio buttons, turn all off except activeItem.
-
- void Dialog_SetRadioGroup(
- DialogPtr theDialog,
- short startItem,
- short endItem,
- short activeItem )
- {
- ControlHandle theControl;
- short i;
-
- for (i = startItem; i <= endItem; i++)
- {
- theControl = (ControlHandle)Dialog_GetItemHandle( theDialog, i );
- if (theControl != nil)
- SetControlValue( theControl, (i == activeItem) ? 1 : 0 );
- }
- }
-
- //---------------------------------------------------------------------------
- // given a dialog box and a range of radio buttons, return the active button's number
- // return zero if none were on.
-
- short Dialog_GetRadioGroup(
- DialogPtr theDialog,
- short startItem,
- short endItem )
- {
- ControlHandle theControl;
- short i;
-
- for (i = startItem; i <= endItem; i++)
- {
- theControl = (ControlHandle)Dialog_GetItemHandle( theDialog, i );
- if (theControl != nil)
- if (GetControlValue( theControl ) != 0)
- break;
- }
-
- if (i > endItem)
- i = 0;
-
- return i;
- }
-
- //---------------------------------------------------------------------------
- // Return the menu handle from a pop up CDEF control. Since we can't call
- // GetMHandle to access the menu handle, we have to look at the data stored
- // in the control record.
-
- MenuHandle GetPopUpMenuHandle(
- ControlHandle thisControl )
- {
- if (thisControl == nil)
- return nil;
-
- return (**((popupPrivateDataHdl)(*thisControl)->contrlData)).mHandle;
- }
-
- //---------------------------------------------------------------------------
- // Set the menu handle of a pop up CDEF control.
- // We have to stuff the data in the control record
-
- void SetPopUpMenuHandle(
- ControlHandle thisControl,
- MenuHandle theMenu )
- {
- if ((thisControl != nil) && (theMenu != nil))
- (**((popupPrivateDataHdl)(*thisControl)->contrlData)).mHandle = theMenu;
- }
-
- //---------------------------------------------------------------------------
- // Given a string and a menu, return the item number of the last menu item
- // that matches the string.
-
- short ItemStringToItem(
- Str255 theItemString,
- MenuHandle theMenu )
- {
- Str255 theString;
- short index;
-
- index = CountMItems( theMenu );
- while (index > 0)
- {
- GetMenuItemText( theMenu, index, theString );
- if (EqualString( theString, theItemString, false, false ))
- break;
-
- index--;
- }
-
- return index;
- }
-
-
- //---------------------------------------------------------------------------
- // Given a font number and a menu, return the last menu item that matches the
- // font's name.
- short FontToMenuItem(
- short fontFamilyNumber,
- MenuHandle theMenu )
- {
- Str255 fontName;
-
- GetFontName( fontFamilyNumber, fontName );
- return ItemStringToItem( fontName, theMenu );
- }
-
-
- //---------------------------------------------------------------------------
- // Given a font size and a menu, return the last menu item that matches the
- // size.
- short SizeToMenuItem(
- short theSize,
- MenuHandle theMenu )
- {
- Str255 theString;
-
- // if (theSize == 9)
- // return(1);
- NumToString( (long)theSize, theString );
- return ItemStringToItem( theString, theMenu );
- }
-
- //----------------------------------------------------------------------------
- // Dialog_GetItemHandle
- Handle Dialog_GetItemHandle(
- DialogPtr theDialog,
- short itemNum )
- {
- Rect itemRect;
- Handle itemHandle;
- short itemKind;
-
- itemHandle = nil;
- if ((theDialog != nil) && (itemNum > 0))
- GetDialogItem( theDialog, itemNum, &itemKind, &itemHandle, &itemRect );
-
- return itemHandle;
- }
-
- //----------------------------------------------------------------------------
- void Dialog_SetItemHandle(
- DialogPtr theDialog,
- short itemNum,
- Handle theHandle )
- {
- Rect itemRect;
- Handle itemHandle;
- short itemKind;
-
- GetDialogItem( theDialog, itemNum, &itemKind, &itemHandle, &itemRect );
- SetDialogItem( theDialog, itemNum, itemKind, theHandle, &itemRect );
- }
-
- //----------------------------------------------------------------------------
- void Dialog_GetItemRect(
- DialogPtr theDialog,
- short theID,
- Rect *theRect )
- {
- Handle itemHandle;
- short itemKind;
-
- GetDialogItem( theDialog, theID, &itemKind, &itemHandle, theRect );
- }
-
- //----------------------------------------------------------------------------
- void Dialog_SetItemRect(
- DialogPtr theDialog,
- short theID,
- Rect *theRect )
- {
- Rect itemRect;
- Handle itemHandle;
- short itemKind;
-
- GetDialogItem( theDialog, theID, &itemKind, &itemHandle, &itemRect );
- SetDialogItem( theDialog, theID, itemKind, itemHandle, theRect );
- }
-
- //----------------------------------------------------------------------------
- short Dialog_GetItemKind(
- DialogPtr theDialog,
- short theID )
- {
- Rect itemRect;
- Handle itemHandle;
- short itemKind;
-
- GetDialogItem( theDialog, theID, &itemKind, &itemHandle, &itemRect );
- return itemKind;
- }
-
- //----------------------------------------------------------------------------
- void Dialog_InvalItemRect(
- DialogPtr theDialog,
- short itemNum )
- {
- Rect theRect;
- GrafPtr savePort;
-
- // make sure the item number is valid.
- // if (itemNum < 1 || itemNum > CountDITL(theDialog))
- // return;
-
- GetPort( &savePort );
- SetPort( theDialog );
- Dialog_GetItemRect( theDialog, itemNum, &theRect );
- InvalRect( &theRect );
- SetPort( savePort );
- }
-
- //----------------------------------------------------------------------------
- void Dialog_OutlineButton(
- DialogPtr theDialog,
- short itemNum )
- {
- Rect theRect;
- PenState pnState;
-
- // make sure the item number is valid.
- // if (itemNum < 1 || itemNum > CountDITL(theDialog))
- // return;
-
- GetPenState( &pnState );
- PenNormal();
- PenSize( 3, 3 );
- Dialog_GetItemRect( theDialog, itemNum, &theRect );
- InsetRect( &theRect,-4, -4 );
- FrameRoundRect( &theRect, 16, 16 );
- SetPenState( &pnState );
- }
-
- //----------------------------------------------------------------------------
- void Dialog_FrameItem(
- DialogPtr theDialog,
- short itemNum )
- {
- Rect theRect;
- PenState pnState;
-
- // make sure the item number is valid.
- // if (itemNum < 1 || itemNum > CountDITL(theDialog))
- // return;
-
- GetPenState( &pnState );
- PenNormal();
- Dialog_GetItemRect( theDialog, itemNum, &theRect );
- FrameRect( &theRect );
- SetPenState( &pnState );
- }
-
- //----------------------------------------------------------------------------
- void Dialog_GrayLine(
- DialogPtr theDialog,
- short itemNum )
- {
- Rect theRect;
- PenState pnState;
-
- GetPenState( &pnState );
- PenNormal();
- PenPat( (ConstPatternParam)&qd.gray ); // ConstPatternParam from non-universal THINK C headers
-
- Dialog_GetItemRect( theDialog, itemNum, &theRect );
- MoveTo( theRect.left, theRect.top );
- if (theRect.right - theRect.left > theRect.bottom - theRect.top)
- LineTo( theRect.right, theRect.top );
- else
- LineTo( theRect.left, theRect.bottom );
-
- SetPenState( &pnState );
- }
-
-
- //----------------------------------------------------------------------------
- void Dialog_SizeTextItem(
- DialogPtr theDialog,
- short itemNum )
- {
- short iFont, iSize;
- Rect theRect;
- Str255 s0;
-
- Dialog_GetItemRect( theDialog, itemNum, &theRect );
- GetDialogItemText( Dialog_GetItemHandle( theDialog, itemNum ), s0 );
- iFont = theDialog->txFont;
- iSize = theDialog->txSize;
- TextFont( systemFont );
- TextSize( 0 );
- theRect.right = theRect.left + TextWidth( s0+1, 0, s0[0] ) + 1;
- TextFont( iFont );
- TextSize( iSize );
- Dialog_SetItemRect( theDialog, itemNum, &theRect );
- }
-
-
- //----------------------------------------------------------------------------
- void Dialog_SetTextItem(
- DialogPtr theDialog,
- short itemNum,
- Str255 theString )
- {
- short iFont, iSize;
- Rect theRect;
- GrafPtr savePort;
-
- GetPort( &savePort );
- SetPort( theDialog );
-
- Dialog_GetItemRect( theDialog, itemNum, &theRect );
- EraseRect( &theRect );
- InvalRect( &theRect );
-
- iFont = theDialog->txFont;
- iSize = theDialog->txSize;
- TextFont( systemFont );
- TextSize( 0 );
- theRect.right = theRect.left + TextWidth( theString+1, 0, theString[0] ) + 1;
- TextFont( iFont );
- TextSize( iSize );
- SetDialogItemText( Dialog_GetItemHandle( theDialog, itemNum ), theString );
-
- SetPort( savePort );
- }
-
-
- //----------------------------------------------------------------------------
- void Dialog_SetUserProc(
- DialogPtr theDialog,
- short itemNum,
- pascal void (*proc)( WindowPtr theWindow, short itemNum ) )
- {
- Rect theRect;
- Handle theHandle;
- short itemKind;
-
- GetDialogItem( theDialog, itemNum, &itemKind, &theHandle, &theRect );
- SetDialogItem( theDialog, itemNum, itemKind, (Handle)proc, &theRect );
- }
-
- //----------------------------------------------------------------------------
- void Dialog_RedrawDialogs( void )
- {
- WindowPeek theWindow;
- GrafPtr savePort;
-
- GetPort( &savePort );
- theWindow = (WindowPeek)FrontWindow();
-
- while (theWindow != nil)
- {
- if (theWindow->windowKind == dialogKind)
- {
- SetPort( (GrafPtr)theWindow );
- if (((DialogPeek)theWindow)->aDefItem)
- Dialog_OutlineButton( (WindowPtr)theWindow, ((DialogPeek)theWindow)->aDefItem ); // iOKITEM
- BeginUpdate( (WindowPtr)theWindow );
- UpdateDialog( (WindowPtr)theWindow, ((WindowPtr)theWindow)->visRgn );
- EndUpdate( (WindowPtr)theWindow );
- }
-
- theWindow = theWindow->nextWindow;
- }
-
- SetPort( savePort );
- }
-
- //----------------------------------------------------------------------------
- short Dialog_GetIconID(
- DialogPtr theDialog,
- short itemNum )
- {
- Str255 sName;
- Rect itemRect;
- ResType theType;
- Handle itemHandle;
- short itemKind, theID;
-
- GetDialogItem( theDialog, itemNum, &itemKind, &itemHandle, &itemRect );
- GetResInfo( itemHandle, &theID, &theType, sName );
-
- return theID;
- }
-
- //----------------------------------------------------------------------------
- void Dialog_DrawCenteredStr(
- DialogPtr theDialog,
- short itemNum,
- StringPtr theString )
- {
- Rect theRect;
- Str255 sDst;
-
- Dialog_GetItemRect( theDialog, itemNum, &theRect );
- sTrimText( theString, sDst, theRect.right-theRect.left );
- sCopyStr( theString, sDst );
- TextBox( sDst+1, (long)sDst[0], &theRect, teJustCenter );
- }
-
- //----------------------------------------------------------------------------
- Boolean Dialog_ControlEnabled(
- ControlHandle theControl )
- {
- return ((**theControl).contrlHilite != (Byte)255);
- }
-
- //----------------------------------------------------------------------------
- void Dialog_BlinkControl(
- ControlHandle theControl )
- {
- long finalTicks;
-
- HiliteControl( theControl, 1 );
- Delay( 8L, &finalTicks );
- HiliteControl( theControl, 0 );
- }
-
- //----------------------------------------------------------------------------
- Boolean bDialogFilter(
- DialogPtr theDialog,
- EventRecord *theEvent,
- short *itemHit,
- Boolean (*filterProc)( DialogPtr, EventRecord*, short* ) )
- {
- char theCharCode;
- short iKind, iItem, iCount, iControlItem;
- Str255 s0;
- ControlHandle hControl;
- Rect rRect;
- GrafPtr savePort;
-
- static long lLastTime = (-1L);
- static Point LastPt = { 0, 0 };
-
- if (filterProc != nil)
- if ((*filterProc)( theDialog, theEvent, itemHit ))
- return true;
-
- switch (theEvent->what)
- {
- case nullEvent:
- if (((DialogPeek)theDialog)->editField != -1)
- {
- GlobalToLocal( &theEvent->where );
- Dialog_GetItemRect( theDialog, ((DialogPeek)theDialog)->editField+1, &rRect );
- if (PtInRect( theEvent->where, &rRect ))
- bSetCursor( iBeamCursor );
- else
- bSetCursor( arrowCursor );
- }
- else
- bSetCursor( arrowCursor );
- break;
-
- case mouseDown:
- // detect double clicks.
- if (((theEvent->when - lLastTime) <= LMGetDoubleTime())
- && bAlmostEqual( LastPt, theEvent->where, 3 ))
- {
- LastPt = theEvent->where;
- GlobalToLocal( &LastPt );
- iItem = FindDialogItem( theDialog, LastPt ) + 1;
- if (iItem > 0)
- {
- GetDialogItem( theDialog, iItem, &iKind, (Handle*)&hControl, &rRect );
- if (iKind == (ctrlItem+radCtrl) && Dialog_ControlEnabled( hControl ))
- {
- if (iOKITEM && Dialog_ControlEnabled(
- (ControlHandle)Dialog_GetItemHandle( theDialog, iOKITEM ) ))
- {
- lLastTime = -1;
- LastPt.h = LastPt.v = 0;
- *itemHit = iOKITEM;
- return true;
- }
- }
- }
- }
-
- lLastTime = theEvent->when;
- LastPt = theEvent->where;
- break;
-
- case keyDown:
- case autoKey:
- // if it was the return or enter key…
- if (iOKITEM
- && (((theEvent->message & charCodeMask) == 3)
- || ((theEvent->message & charCodeMask) == 13)))
- {
- // if the OK button is enabled, hit it
- hControl = (ControlHandle)Dialog_GetItemHandle( theDialog, iOKITEM );
- if (Dialog_ControlEnabled( hControl ))
- {
- Dialog_BlinkControl( hControl );
- *itemHit = iOKITEM;
- return true;
- }
- else // otherwise convert the key into a tab and let it go
- {
- theEvent->message = 9; // change it into a tab
- return false;
- }
- }
-
- // if it was the escape key or cmd-. and the cancel button is enabled…
- hControl = (ControlHandle)Dialog_GetItemHandle( theDialog, iCancelITEM );
- if (iCancelITEM
- && (((theEvent->message & charCodeMask) == kEscape)
- || (((theEvent->message & charCodeMask) == '.') && (theEvent->modifiers & cmdKey)))
- && Dialog_ControlEnabled( hControl ))
- {
- // hit the cancel button and get out.
- Dialog_BlinkControl( hControl );
- *itemHit = iCancelITEM;
- return true;
- }
-
- // if the cmd key is down and there is an edit field, handle cut/copy/paste
- if ((theEvent->modifiers & cmdKey) && ((DialogPeek) theDialog)->editField != -1)
- {
- long theLength, scrapOffset;
-
- // $$$$$ this stuff may not be necessary if we're running System 7.
- switch (cUpperCase( theEvent->message & charCodeMask ))
- {
- case 'X':
- if ((**((DialogPeek)theDialog)->textH).selEnd > (**((DialogPeek) theDialog)->textH).selStart)
- {
- ZeroScrap(); // in this case we must clear the current scrap
- TECut( ((DialogPeek)theDialog)->textH );
- TEToScrap(); // in this case we must force our cut into the scrap
- }
- return true; // we handled it.
-
- case 'C':
- if ((**((DialogPeek)theDialog)->textH).selEnd > (**((DialogPeek)theDialog)->textH).selStart)
- {
- ZeroScrap(); // in this case we must clear the current scrap
- TECopy( ((DialogPeek)theDialog)->textH );
- TEToScrap(); // in this case we must force our cut into the scrap
- }
- return true; // we handled it.
-
- case 'V':
- // Get the length of the TEXT on the clipboard
- theLength = GetScrap( nil, 'TEXT', &scrapOffset );
-
- // make sure the paste won't result in over 32K of text.
- if ((theLength > 0) && ((unsigned long)(**((DialogPeek)theDialog)->textH).teLength
- - ((**((DialogPeek)theDialog)->textH).selEnd - (**((DialogPeek)theDialog)->textH).selStart)
- + theLength) > kMaxTextLength)
- SysBeep( 2 );
- else
- TEPaste( ((DialogPeek)theDialog)->textH );
- return true; // we handled it.
-
- default:
- return false; // we did not handle it.
- }
- // *itemHit = 0;
- return false; // we did not handle it.
- }
-
- // if the cmd key is down or there's no edit field, handle keyboard equivs.
- if ((theEvent->modifiers & cmdKey) || (((DialogPeek)theDialog)->editField == -1))
- {
- /* handle command keys (or normal keys if no text edit field) for buttons */
- theCharCode = cUpperCase( theEvent->message & charCodeMask );
- iCount = iControlItem = 0;
- for (iItem=1; iItem <= **((short**)(((DialogPeek)theDialog)->items))+1; iItem++)
- {
- GetDialogItem( theDialog, iItem, &iKind, (Handle*)&hControl, &rRect );
- if ((iKind & 0x04) && !(iKind & 0x80))
- {
- /* control kind and not disabled */
- if ((rRect.left < 8192) && /* HideDItem adds 16384 to control to hide 'em */
- ((**hControl).contrlVis == 255) &&
- Dialog_ControlEnabled( hControl ))
- {
- GetControlTitle( hControl, s0 );
- if (s0[0] != '\0')
- {
- if (theCharCode == cUpperCase( s0[1] ))
- {
- iCount++;
- iControlItem = iItem;
- }
- }
- }
- }
- }
-
- // if there is exactly one control that begins with the command letter,
- // then hit it.
- if (iCount == 1)
- {
- hControl = (ControlHandle)Dialog_GetItemHandle( theDialog, iControlItem );
- Dialog_BlinkControl( hControl );
- *itemHit = iControlItem;
- return true; // we handled it.
- }
-
- // theEvent->what = nullEvent; /* don't accept other keystrokes when cmd key is down */
- }
- break;
-
- case updateEvt:
- if (theEvent->message == (long)theDialog) // if it's us…
- {
- // and we need updating…
- if (!EmptyRgn( ((WindowPeek)theDialog)->updateRgn ))
- {
- GetPort( &savePort );
- SetPort( theDialog );
-
- // iOKITEM
- if (((DialogPeek)theDialog)->aDefItem != 0)
- Dialog_OutlineButton( theDialog, ((DialogPeek)theDialog)->aDefItem );
-
- BeginUpdate( theDialog );
- UpdateDialog( theDialog, theDialog->visRgn );
- EndUpdate( theDialog );
- SetPort( savePort );
- }
- return false; // we handled it, but still return false!
- }
- break;
- }
- return false; // we did not handle it.
- }
-
- //----------------------------------------------------------------------------
- pascal Boolean bGenericDialogFilter(
- DialogPtr theDialog,
- EventRecord *theEvent,
- short *itemHit )
- {
- return bDialogFilter( theDialog, theEvent, itemHit, 0L );
- }
-
-